// Usage:
// At top of main: import MemHack from './MemHack'
// At top of loop(): MemHack.pretick()
// Thats it!
let lastTime=0;
const MemHack = {
    memory: undefined as (Memory|undefined),
    parseTime: -1,
    register () {
        const start = Game.cpu.getUsed()
        this.memory = global.Memory
        const end = Game.cpu.getUsed()
        this.parseTime = end - start
        // this.memory = RawMemory._parsed
    },
    pretick () {
        if (lastTime&& this.memory && Game.time == lastTime+1) {
            delete global.Memory
            global.Memory = this.memory
            RawMemory._parsed = this.memory
        }
        else
        {
            this.memory =  global.Memory;
        }
        lastTime=Game.time;
    },
}
MemHack.register()

export default MemHack
